﻿import QtQuick 2.15
import QtQuick.Controls 2.15

Item {
    id: itemChangeUserInfo
    anchors.fill: parent
    visible: false

    MouseArea{
        anchors.fill: parent

        onPressed: {
            itemChangeUserInfo.visible = false
        }
    }

    Rectangle{
        id: rectChangeUserInfo
        width: parent.width*0.6
        height: parent.height*0.4
        color: "#404142"
        anchors.verticalCenter: parent.verticalCenter
        anchors.horizontalCenter: parent.horizontalCenter

        MouseArea{
            anchors.fill: parent
        }

        Button {
            id: leftChangeUserInfo
            width: parent.height*0.2
            height: width/2
            anchors.left: parent.left
            anchors.bottom: parent.bottom
            anchors.leftMargin: width
            anchors.bottomMargin: height
            text: "确定"

            onClicked: {
                var name = inputChangeUserName.text
                var number = inputChangeUserAccount.text
                var img = inputChangeUserPortrait.text
                dbManager.updatetUserInfo("UserInfo", name, number, img)

                //刷新页面
                pageStackView.clear(StackView.Immediate)
                pageStackView.push("FirstPage.qml", StackView.Immediate)

            }
        }
        Button {
            id: rightChangeUserInfo
            width: parent.height*0.2
            height: width/2
            anchors.right: parent.right
            anchors.bottom: parent.bottom
            anchors.rightMargin: width
            anchors.bottomMargin: height
            text: "取消"

            onClicked: {
                itemChangeUserInfo.visible = false
            }
        }

        Text {
            id: textChangeUserName
            color: "#ffffff"
            text: qsTr("名称：")
            anchors.left: parent.left
            anchors.top: parent.top
            horizontalAlignment: Text.AlignHCenter
            verticalAlignment: Text.AlignVCenter
            anchors.leftMargin: parent.width*0.2
            font.bold: true
            font.pointSize: 10
            anchors.topMargin: parent.height*0.2
        }

        TextInput{
            id: inputChangeUserName
            anchors.left: textChangeUserName.right
            anchors.top: parent.top
            anchors.topMargin: parent.height*0.2
            maximumLength: 6
            width: parent.width*0.4
            height: textChangeUserName.height
            color: "#000000"
            anchors.leftMargin: height
            selectByMouse: true
            leftPadding: 2
            topPadding: 1
            z: 2
        }
        Rectangle{
            anchors.fill: inputChangeUserName
            color: "#ffffff"
            z: 1
        }

        Text {
            id: textChangeUserAccount
            color: "#ffffff"
            text: qsTr("账号：")
            anchors.left: parent.left
            anchors.top: parent.top
            horizontalAlignment: Text.AlignHCenter
            verticalAlignment: Text.AlignVCenter
            anchors.leftMargin: parent.width*0.2
            font.bold: true
            font.pointSize: 10
            anchors.topMargin: parent.height*0.4
        }

        TextInput{
            id: inputChangeUserAccount
            anchors.left: textChangeUserAccount.right
            anchors.top: parent.top
            anchors.topMargin: parent.height*0.4
            maximumLength: 6
            width: parent.width*0.4
            height: textChangeUserAccount.height
            color: "#000000"
            anchors.leftMargin: height
            selectByMouse: true
            leftPadding: 2
            topPadding: 1
            z: 2
        }

        Rectangle{
            anchors.fill: inputChangeUserAccount
            color: "#ffffff"
            z: 1
        }

        Text {
            id: textChangeUserPortrait
            color: "#ffffff"
            text: qsTr("头像：")
            anchors.left: parent.left
            anchors.top: parent.top
            horizontalAlignment: Text.AlignHCenter
            verticalAlignment: Text.AlignVCenter
            anchors.leftMargin: parent.width*0.2
            font.bold: true
            font.pointSize: 10
            anchors.topMargin: parent.height*0.6
        }

        TextInput{
            id: inputChangeUserPortrait
            anchors.left: textChangeUserPortrait.right
            anchors.top: parent.top
            anchors.topMargin: parent.height*0.6
            maximumLength: 15
            width: parent.width*0.4
            height: textChangeUserPortrait.height
            color: "#000000"
            anchors.leftMargin: height
            selectByMouse: true
            leftPadding: 2
            topPadding: 1
            z: 2
        }

        Rectangle{
            anchors.fill: inputChangeUserPortrait
            color: "#ffffff"
            z: 1
        }

    }

}

/*##^##
Designer {
    D{i:0;autoSize:true;height:480;width:640}
}
##^##*/
